package com.gitee.es.dynamics.config;

import com.gitee.es.dynamics.common.ContextHolderInit;
import com.gitee.es.dynamics.common.ElasticSearchConfig;
import com.gitee.es.dynamics.context.DynamicsElasticSearchContextHolder;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import java.util.List;

@ConfigurationProperties(prefix = "spring.elasticsearch.dynamics")
@Data
public class DynamicsElasticSearchConfig implements ContextHolderInit {

    /**
     * es多数据源配置
     */

    private List<ElasticSearchConfig> configs;


    /**
     * 是否开启sql配置动态数据源
     */
    private Boolean openSqlConfig = false;

    @Override
    @PostConstruct
    public void init() {
        DynamicsElasticSearchContextHolder.setDynamicsElasticSearchConfig(this);
    }
}


